package com.hs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.Psych;
import com.hs.mapper.PsychMapper;
import com.hs.service.PsychService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PsychServiceImpl implements PsychService {
    @Autowired
    private PsychMapper psychMapper;
    @Override
    public int addPsych(Psych psych) {
        return psychMapper.addPsych(psych);
    }

    @Override
    public int deletePsych(int id) {
        return psychMapper.deletePsych(id);
    }

    @Override
    public int updatePsych(Psych psych) {
        return psychMapper.updatePsych(psych);
    }

    @Override
    public Psych getPsychById(int id) {
        return psychMapper.getPsychById(id);
    }

    @Override
    public PageInfo<Psych> getPsychsByPage(Psych psych, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Psych> list = psychMapper.getPsychsByPage(psych);
        PageInfo<Psych> pageInfo = new  PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<Psych> getAllPsychs() {
        return psychMapper.getAllPsychs();
    }

    @Override
    public Psych getOnlyPsychById(int id) {
        return psychMapper.getOnlyPsychById(id);
    }
}
